package com.example.service.Impl;

import cn.hutool.core.bean.BeanUtil;
import com.example.entity.dto.UserDto;
import com.example.entity.pojo.User;
import com.example.mapper.UserMapper;
import com.example.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public int register(UserDto userDto) {
        // 判断两次密码是否一致
        if (!userDto.getPassword().equals(userDto.getPassword1())) {
            return 0;
        }
        // 对象拷贝
        User user = BeanUtil.copyProperties(userDto, User.class);
        // 调用mapper类
        return userMapper.register(user);
    }
}
